package org.baicaixiaozhan.springbootwebdemo1.domain;

import com.google.common.collect.ImmutableSet;

import java.util.Set;

/**
 * @author baicaixiaozhan
 * @since 2021/1/29
 */
public enum UserRole {
    // 角色: 学生
    ROLE_STUDENT(ImmutableSet.of("read", "update")),
    // 角色: 老师
    ROLE_TEACHER(ImmutableSet.of("read", "add", "update")),
    // 角色: 管理员
    ROLE_ADMIN(ImmutableSet.of("read", "add", "update", "delete"));

    UserRole(Set<String> permissions) {
        this.permissions = permissions;
    }

    /**
     * 角色下可行的权限
     */
    private Set<String> permissions;

    public Set<String> getAuthorities() {
        return permissions;
    }
}
